import pygame
from pygame.sprite import Sprite


class PlayerBullet(Sprite):
    def __init__(self, game):
        super().__init__()
        self.main_screen = game.screen
        self.height = 30
        self.width = 5
        self.color = (0, 150, 255)
        # create rect as bullet and set pos
        self.rect = pygame.Rect(0, 0, self.width, self.height)
        self.rect.midtop = game.player.rect.midtop
        self.y = float(self.rect.y)
        self.player_bullet_speed = 8.0

    def update(self):
        self.y -= self.player_bullet_speed
        self.rect.y = self.y

    def draw(self):
        pygame.draw.rect(self.main_screen, self.color, self.rect)
